﻿<!doctype html>
<html>
<head>
    <title>SpreadJS - Sheet Header</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>

    <link href="../../../external/spreadjs/css/gcspread.sheets.excel2013white.9.40.20161.0.css" rel="stylesheet" type="text/css" />

    <script src="../../../external/external/jquery-1.8.2.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="../../../external/spreadjs/gcspread.sheets.all.9.40.20161.0.min.js"></script>

    <script id="scriptInit" type="text/javascript">
    /*code_begin*/
        $(document).ready(function () {
            var spread = new GcSpread.Sheets.Spread(document.getElementById("ss"));
            var spreadNS = GcSpread.Sheets;
            var sheet = spread.getSheet(0);
            sheet.isPaintSuspended(true);
            //Set rowHeader count and columnHeader count.
            sheet.setRowCount(3, spreadNS.SheetArea.colHeader);
            sheet.setColumnCount(3, spreadNS.SheetArea.rowHeader);

            //Change header "auto text".
            sheet.setColumnHeaderAutoTextIndex(1);
            sheet.setColumnHeaderAutoText(spreadNS.HeaderAutoText.numbers);
            sheet.isPaintSuspended(false);

            /*
            * Show or hide the row header.
            */
            $("#chkRowHeaderVisible").click(function () {
                var sheet = spread.getActiveSheet();

                sheet.setRowHeaderVisible($(this).prop("checked"));

                spread.invalidateLayout();
                spread.repaint();
            });

            /*
            * Show or hide the column header.
            */
            $("#chkColumnHeaderVisible").click(function () {
                var sheet = spread.getActiveSheet();

                sheet.setColumnHeaderVisible($(this).prop("checked"));

                spread.invalidateLayout();
                spread.repaint();
            });

            $("#btnSetAutoText").click(function () {
                var headerType = $("input[name='headerType']:checked").val(),
                    headerAutoTextType = $("#headerAutoTextType option:checked").val();

                if (headerAutoTextType) {
                    headerAutoTextType = spreadNS.HeaderAutoText[headerAutoTextType];

                    if (!(headerAutoTextType === undefined)) {
                        switch (headerType) {
                            case "row":
                                sheet.setRowHeaderAutoText(headerAutoTextType);
                                break;
                            case "column":
                                sheet.setColumnHeaderAutoText(headerAutoTextType);
                                break;
                        }
                    }
                }
            });
        });
    /*code_end*/
    </script>
</head>
<body>
    <div class="sample-turtorial">
        <div id="ss" style="width:100%; height:415px;border: 1px solid gray;"></div>
        <div class="demo-options">
            <div class="option-row">
                <input type="checkbox" id="chkColumnHeaderVisible" checked />
                <label for="chkColumnHeaderVisible">ColumnHeaderVisible</label>
            </div>
            <div class="option-row">
                <input type="checkbox" id="chkRowHeaderVisible" checked />
                <label for="chkRowHeaderVisible">RowHeaderVisible</label>
            </div>
            <div class="option-row">
                <input type="radio" name="headerType" value="row" id="headerTypeRow" /><label for="headerTypeRow">Row</label> 
                <input type="radio" name="headerType" value="column" id="headerTypeColumn" checked="checked" /><label for="headerTypeColumn">Column</label> 
                <label for="headerAutoTextType" style="display:inline-block;margin-left:12px;margin-right: 8px;">Header Auto Text type: </label>
                <select id="headerAutoTextType">
                    <option value="blank">Blank</option>
                    <option value="letters" selected="selected">Letters</option>
                    <option value="numbers">Numbers</option>
                </select>
                <input type="button" id="btnSetAutoText" value="Set" />
            </div>
        </div>
    </div>
</body>
</html>